Using
the PCMWAVEFORMAT Structure
For PCM audio
data, use the PCMWAVEFORMAT9TZNQJ.
UINT wReturn;
PCMWAVEFORMAT pcmWaveFormat;
// Set up PCMWAVEFORMAT for 11 kHz 8-bit mono.
pcmWaveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.wf.nChannels = 1;
pcmWaveFormat.wf.nSamplesPerSec = 11025L;
pcmWaveFormat.wf.nAvgBytesPerSec = 11025L;
pcmWaveFormat.wf.nBlockAlign = 1;
pcmWaveFormat.wBitsPerSample = 8;
// See if format is supported by any device in
system.
wReturn = IsFormatSupported(&pcmWaveFormat,
WAVE_MAPPER);
// Report results.
if (wReturn == 0)
MessageBox(hMainWnd, "11 kHz 8-bit mono is supported.",
"", MB_ICONINFORMATION);
else if (wReturn == WAVERR_BADFORMAT)
MessageBox(hMainWnd, "11 kHz 8-bit mono NOT supported.",
"", MB_ICONINFORMATION);
else
MessageBox(hMainWnd, "Error opening waveform device.",
"Error", MB_ICONEXCLAMATION);
// Set up PCMWAVEFORMAT for 44.1 kHz 16-bit stereo.
pcmWaveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.wf.nChannels = 2;
pcmWaveFormat.wf.nSamplesPerSec = 44100L;
pcmWaveFormat.wf.nAvgBytesPerSec = 176400L;
pcmWaveFormat.wf.nBlockAlign = 4;
pcmWaveFormat.wBitsPerSample = 32;
// See if format is supported by any device in the
system.
wReturn = IsFormatSupported(&pcmWaveFormat,
WAVE_MAPPER);
/ Report results.
if (wReturn == 0)
MessageBox(hMainWnd, "44.1 kHz 16-bit stereo is supported.",
"", MB_ICONINFORMATION);
else if (wReturn == WAVERR_BADFORMAT)
MessageBox(hMainWnd, "44.1 kHz 16-bit stereo NOT supported.",
"", MB_ICONINFORMATION);
else
MessageBox(hMainWnd, "Error opening waveform device.",
"Error", MB_ICONEXCLAMATION);